<?php
/**
 * Created by PhpStorm.
 * User: user
 * Date: 2016/4/12
 * Time: 14:20
 */

use yii\helpers\Html;
use front\assets\AppAsset;
use yii\helpers\Url;

?>

<body class="m-feedback">

    <div class="m-input-row">
        <textarea id="content" class="form-control m-fb-content" rows="8" placeholder="请输入反馈意见,我们会以消息形式回复您的建议或意见,改进用户体验,谢谢!"></textarea>
        <span class="m-textarea-num">0字</span>
    </div>

    <div class="m-input-padding">
<!--        <h1>上传图片 <small>(最多上传3张图片,选填)</small></h1>-->
<!--        <p>-->
<!--            <img src="img/tmp005.jpg">-->
<!--            <img src="img/tmp005.jpg">-->
<!--            <a class="m-upload-btn" href="javascript:;">-->
<!--                <input type="file" onchange="upfile(this);" accept="image/jpg,image/jpeg,image/png,image/gif" multiple="multiple" /><span>&nbsp;</span>-->
<!--            </a>-->
<!--        </p>-->

        <button onclick="submit();" class="m-fb-submit">提交</button>
    </div>


<script>
    // 判断是否IOS设备
    var isIOS = /(iPhone|iPod|iPad|ios)/i.test(navigator.userAgent);
    if(isIOS){
        // 检测粘贴
        document.getElementById('content').addEventListener('paste', function(){
            setTimeout(function() {
                var length = $('#content').val().length;
                $('.m-textarea-num').text(length + '字');
            }, 500);
        });

        // 检测复制
        document.getElementById('content').addEventListener('copy', function(){
            setTimeout(function() {
                var length = $('#content').val().length;
                $('.m-textarea-num').text(length + '字');
            }, 500);
        });
    }
    $('.m-fb-content').on('keyup', function() {
        var length = $(this).val().length;
        $('.m-textarea-num').text(length+'字');
    });

    function upfile(ob){

        var dir = ob.value;
        if(dir.length <= 0) return !1;

        var ext = /\.[^\.]+$/.exec(dir)[0];

        if(ext !== '.jpg' || ext !== '.png' || ext !== '.gif'){
            console.log('格式错误');
            return !1;
        }

        // ......
    }

    function submit()
    {
        var content = $.trim($('#content').val());
        if (content.length <= 0) {
            msgPopup("请填写您的建议~");
            return !1;
        }

        var params = {};
        params.content = content;
        $.post("", params, function(data) {
            if(data == 1) {
                msgPopup("感谢您对秀贝的关注~");
                setTimeout(function() {
                    window.location.href = '<?=\yii\helpers\Url::to(['my/index'])?>';
                }, 1500);

            }else {
                msgPopup(data);
            }
        })
    }
</script>
</body>













